package com.xxxx.manager;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.xxxx.persistence.domain.UserDO;
import com.xxxx.persistence.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName: UserManager
 * @Description: 用户管理器
 * @Author: ZhouWei
 * @Date: 2023-4-16 - 17:13
 */
@Component
public class UserManager {

    @Autowired
    private UserRepository userRepository;

    @DS("master")
    public UserDO readDataSource0(Long userId) {
        return userRepository.selectById(userId);
    }

    @DS("master")
    public int writeDataSource0(UserDO user) {
        return userRepository.insert(user);
    }

    @DS("slave")
    public UserDO readDataSource1(Long userId) {
        return userRepository.selectById(userId);
    }

    @DS("slave")
    public int writeDataSource1(UserDO user) {
        return userRepository.insert(user);
    }
}
